using System;
using System.Web.UI;

namespace SharpPieces.DemoApp
{

    /// <summary>
    /// The Captcha Image Validation demo page.
    /// </summary>
    public partial class CaptchaImgValidation : Page
    {

        /// <summary>
        /// Handles the Click event of the Button1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.CaptchaImage1.IsValid(this.TextBox1.Text, true))
            {
                this.Label2.Text = "OK";
            }
            else
            {
                this.Label2.Text = "NOK";
            }

            if (this.CaptchaImage2.IsValid(this.TextBox2.Text, true))
            {
                this.Label4.Text = "OK";
            }
            else
            {
                this.Label4.Text = "NOK";
            }
        }

        /// <summary>
        /// Handles the SelectedIndexChanged event of the DropDownList1 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.CaptchaImage1.TextLength = int.Parse(this.DropDownList1.SelectedValue);
            this.CaptchaImage1.ResetText();
        }
        /// <summary>
        /// Handles the Click event of the Button2 control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Button2_Click(object sender, EventArgs e)
        {
            this.CaptchaImage2.ResetText();
        }
    }

}
